import java.util.List;

public class Solution {

    public boolean isContain(Point p, List<Point> points) {
        int n = points.size();
        int count = 0;
        for (int i = 0; i < n; i++) {
            Point p1 = points.get(i);
            Point p2 = points.get((i + 1) % n);

            if (p.getY() > Math.min(p1.getY(), p2.getY()) && p.getY() <= Math.max(p1.getY(), p2.getY())) {
                if (p.getX() <= Math.max(p1.getX(), p2.getX())) {
                    if (p1.getY() != p2.getY()) {
                        if (p1.getX() == p2.getX()) {
                            count++;
                        }else {
                            double k =(p1.getY()-p2.getY())/(p1.getX()-p2.getX());
                            double x =(p.getY()- p1.getY())/k+p1.getX();
                            if (p.getX()<=x){
                                count++;
                            }
                        }
                    }
                }
            }
        }
        return count % 2 != 0;
    }
}
